<?php
/**
 * Created by PhpStorm.
 * User: songshuai@foxmail.com
 * Date: 2019/12/9
 * Time: 14:12
 */

namespace app\components\Pay;


use app\components\Pay\AlipayPack\sdk\Alipay;
use app\components\Pay\weixinPatSDK\WeixinPay;
use app\models\money\MoneyPay;
use app\components\API;

class PayService
{

    public static function getConfigAlipay(){
        return [
            //应用ID,您的APPID。
            'app_id' => "2019072565963731",
            //商户私钥，您的原始格式RSA私钥
            'merchant_private_key' => 'MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCalgVTpshLbdUZy5sY+U9jGPddaEaAEeOeUS1KKg8FbKZ3FXTPY9Se38MhJwsO9PaT76MYAANOV56l1vdD0ZeUsTlE+oDPiiWkFjoHrWDFUmNEV5pKA/fjFMx20gZvBMgC3ewz/tCiN2WGVJx+jTJ+G+nLu7v+T/1VWcfa//mvvYB/MgRGjBnqitOIq5PxCIIFoHxLWlJso9Vqdicvd9S1DM1Ha4irAD93vR6ytxBS1g9Abn4a7RDZ/dQEVX0WGljO5lOXVASJ3N2UqiXBJI/3rOl/4wnDhIBZfl2kq41x1i8sNBOfpR5qiRvuwdrxEJvpm2IRROK9vRWRqlOGCK6/AgMBAAECggEBAJQSNUH+VIbjyqatv395dxBuHqtrMXSFLik8iowqoz7H5t/UPpJUhpozrZ343v/RpsrnVKqtgH0vMniZ4zkj7vTvmPK4nF+vbQSygZ1O9o2rsAgLfW9+Q5hRGNSLsrvusYMFfbYEU2W+eFHmhAw4RXBEXnrW9WjQx9FUcToVzN4GwaK3J2CdC8LdQcr0T8GES29feJvP07FV5XbYmzuoFER2Y2kIoyajTX5hRcLJTRx7rPLRltSRDxXHqDSLBoMyu9ZmYyCTXBNB34QbBKH6oRZJA6dkfrpzVa6qD0WB+d9EZGOLzsJ3NXsw4Hj7ojOituK8VOMjVz0oTxBnGllyymkCgYEA1UcSoPJ+6d2T56XtI+DNecdOpTknKgmPS9Dufm6QxugpOoFpuEt84LhbERoyoCPcGJPdmSzHvJms751KIvU0Bxqto4rui/wxUlTbtno/NG+v6Lb+iDyPUuj1oaiMwgWT91I9TQF736Gat9wNJkswfMZqajyfusDLU8q4dCu7eisCgYEAuY06emgw+aZU/tTdqA0+yMHyj3vWBm62Z4+tUuSe+HIIAM1B9xGTWO7+yupMZeIaEoqgT4znrrtSzgu5Nizqra8bTI9wS6W8I3NXukOmEvEwg2QYPFGWg1XwJmdLcIvmM8o4zF/6oh7iCShOken+5HwqWdc6zZNVK8Asr+1A970CgYBNNwkQihrWsqjssg7z8VyS3Uyk1tdOCd3+VesyjPcPfFgI3XeYCIRym2wk+fYgMjtqDoapASRjLMQGkEyZ8WpftBHvZspMlgaJRz2wh/vAETt/pljqm/pLyxm66FnlmL1kSjr1WTcu1MQ+EoYUOh6Y3gEC62Xs6AX1FSzIqliatwKBgEPLVwdsVCCS5lEpY0dId50QR9im7V7ySpDyDOjRgUfTGht441YrRMPkppFrI7jB8La/ka0fFXNhG/MOk4A4zxHgfb/uVKA/EMt/FBmJJ/+ZwhjvlG9NfAnGd3UAnq6jXtujUjdSBhf/4qRn5rUnYqsGts6WdfSwlRjkIS+yJt+dAoGAYMqXUF2107PzDCNo6F6xdkG35RCc5vCPcR0k4n1ZuoJ20R27m3gbBpE9+fTLZkJ1g/EOw1/k1cqXWF8DdCMqWGdNXHVffOzpAgdZMDVMosy3INRVxVm4JoeJ/LSrtg3UasD9OYP4niRG+uwjD72sPdeHSDPLGvRirs02TUspomY=',
             //编码格式
            'charset' => "UTF-8",
            //签名方式
            'sign_type'=>"RSA2",
            //支付宝网关
            'gatewayUrl' => "https://openapi.alipay.com/gateway.do",
            //支付宝公钥,查看地址：https://openhome.alipay.com/platform/keyManage.htm 对应APPID下的支付宝公钥。
            'alipay_public_key' =>'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA1YscUtdEVpY6nGc27+Wj3vinvIBM9EAmjwZXxtN/3vfIQb2qatrR6ErJgAmB6imXrIgZaCtMDgqWRpYDhR5qaC9DZCN4rF5T9XXlu6lSEyNpHzDHZYfuYXpBacTL3q0vWfdZ3lJMSbfSApbGpy/PzpNVgKPLPJP7b9J0YCfB1HW+jAc6xefKIgtMq0RBKMjg3XzH6t9FYFz/nkOIsaqJGTaQ8v2bqb/fw06LSnkmQVQN6Wm8k06+Mcl/UkA3Ar0cKjvJCp/CSL/3yvcFGQhU7FqEzQyqWSuAb6dHfDgtFh2BcRBub2LhO/WM5jww5BP454j4Pconxq+oeC22VUIRYQIDAQAB',

            /*
            'notify_alipay'=>'http://www.fuzhuangchangongxiao.cn/home/api/notify_alipay',
            'success'=>'http://www.fuzhuangchangongxiao.cn/home/api/success',
*/
            /*
            'notify_alipay'=>'http://www.fuzhuangchangongxiao.cn/api/pay/alipay/notify_alipay',
            'success'=>'http://www.fuzhuangchangongxiao.cn/h5/my/money/success',
*/


            'notify_alipay'=>'http://test.fuzhuangchangongxiao.cn/home/api/notify_alipay',
            'success'=>'http://test.fuzhuangchangongxiao.cn/home/api/success',


        ];
    }

    /**
     * 创建支付订单
     * $play_type 支付类型
     * $money  支付钱数
     * $uid 用户
     *$desc 描述
    */
    public function createOutTradeNo($play_type, $money,$out_trade_no,$desc=''){

        if($play_type!=MoneyPay::pay_type_weixin&&
            $play_type!=MoneyPay::pay_type_zhifubao){
            API::echo_json(1,'支付类型参数错误');
        }
        $pay=null;
        if($play_type==MoneyPay::pay_type_zhifubao){
            $pay=new Alipay();
        }elseif ($play_type==MoneyPay::pay_type_weixin){
             $pay=new WeixinPay();
        }
        return $pay->create($money,$out_trade_no,$desc);
    }
}

/***
"https://openapi.alipay.com/gateway.do?alipay_sdk=alipay-sdk-php-20161101&app_id=2019072565963731
 * &biz_content={"productCode":"QUICK_WAP_PAY","body":"平台现金充值,用户id:71","subject":"充值",
 * "out_trade_no":"y202008230508372590","total_amount":"100","timeout_express":"1m"}
 * &charset=UTF-8&format=json&method=alipay.trade.wap.pay&notify_url
 * =http://www.fuzhuangchangongxiao.cn/api/pay/alipay/notify_alipay&return_url
 * =http://www.fuzhuangchangongxiao.cn/h5/my/money/success&sign_type=RSA2&timestamp
 * =2020-08-23 17:10:37&version=1.0&sign=W8cAHadFPIc0SfbCMboS0GHC20idBZGBNGmXugb%2Fjw4EpBiTfQCvZ%2
 * BuicgBVkWE9vBm1b2FjLtKRlJHtFgaGOdkcBxkkNsQPhgdGQB4rucYTIW2Ru9tZkAN3nwjAwI78lQqFNYnn706e3wwUaust
 * rp9ujS2m1Po04hXwwDF%2FMio0jPCBQeifDNclxKM%2FRnlgP6rBkEXi490QN%2Fg4StErN1GECA%2FdJO%2Fa6dUQIAZjp
 * lRHNUkQAepHguu%2FMgxmGT8kk8lj9TqGGFe%2Fmk%2FA3wMOW9%2F9z41Xk5dGoSRM3Vdw6QV14F5sV7%2F%2FNgQp8HxV7H
 * yb%2BRuDx%2BPOF8dfeU5zL%2FrNfA%3D%3D"

 */